﻿using Microsoft.Practices.Unity;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Commands.Behaviors.Building;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Commands.Behaviors.CodeAnalysis;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Commands.Behaviors.CodeAnalysis.Metrics;
using Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Commands.Behaviors.CodeAnalysis.Inspection;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.Commands
{
    [MenuCommand(Constants.MultiProject.Id, Constants.MultiProject.Analyze)]
    public class AnalyzeMultiProjectCommand : CodeAnalysisCommandBase
    {
        public AnalyzeMultiProjectCommand(IUnityContainer container)
            : base(container)
        {
            if (ShouldCalculateMetrics())
            {
                Behaviors.Add(new ValidateMetricsAvailabilityBehavior(container));
            }
            if (ShouldInspect())
            {
                Behaviors.Add(new ValidateFxCopCmdAvailabilityBehavior(container));
            }

            Behaviors.Add(new BuildSelectedProjectsBehavoir(container));

            if (ShouldCalculateMetrics())
            {
                Behaviors.Add(new CreateMultiProjectMetricsCalculatorBehavior(container));
            }
            if (ShouldInspect())
            {
                Behaviors.Add(new CreateMultiProjectInspectorBehavior(container));
            }

            Behaviors.Add(new PerformCodeAnalysisBehavior(container));

            if (ShouldCalculateMetrics())
            {
                Behaviors.Add(new ShowCodeMetricsCalculationResultBehavior(container));
            }
            if (ShouldInspect())
            {
                Behaviors.Add(new ShowCodeInspectionResultBehavior(container));
            }
        }
    }
}
